package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import com.qf.service.DtsPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.security.Permission;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class DtsPermissionServiceImpl implements DtsPermissionService {
    @Autowired
    DtsPermissionMapper dtsPermissionMapper;

    @Override
    public Set<String> findPermissionById(Integer[] roleIds) {
        LambdaQueryWrapper<DtsPermission> qw = new LambdaQueryWrapper<>();
        qw.in(DtsPermission::getRoleId,roleIds);
        List<DtsPermission> dtsPermissions = dtsPermissionMapper.selectList(qw);
        Set<String> permission = dtsPermissions.stream().map(Permission -> {
            return Permission.getPermission();
        }).collect(Collectors.toSet());

        return permission;
    }
}
